import Vue from 'vue';
import VueRouter from 'vue-router';
// import home from '@/hmoe'

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    component: () => import('@/layout'),
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: () => import('@/views/home'),
        meta: {
          active: 0,
          isShow: true,
        },

        children: [
          {
            path: '/home',
            component: () => import('@/views/goods/goodslist.vue'),
          },
        ],
      },
      {
        path: '/views/address',
        component: () => import('@/views/address'),
        meta: {
          active: 0,
          isShow: false,
        },
      },

      {
        path: '/login',
        component: () => import('@/views/Login'),
        meta: {
          title: '嗨购登录',
        },
      },
      {
        path: '/loginCode',
        component: () => import('@/views/Login/login_code'),
      },
      {
        path: '/loginSu',
        component: () => import('@/views/Login/login_success'),
      },
      {
        path: '/reg',
        component: () => import('@/views/reg'),
      },
      {
        path: '/sendCode/:tel',
        component: () => import('@/views/reg/sendCode'),
        props: true,
      },
      {
        path: '/setPwd/:tel',
        component: () => import('@/views/reg/setPwd'),
        props: true,
      },
      {
        path: '/cartIndex',
        component: () => import('@/views/carts')

      },
      {
        path: '/goodsinfo',
        component: () => import('@/views/goods/goodsinfo'),
        meta: {
          title: '首页',
          active: 0,
          isShow: true,
        },
      },
    ],
  },
  {
    path: '/categorymain',
    redirect: '/category',
    component: () => import('@/layout'),
    children: [
      {
        path: '/category',
        redirect: '/phoneList/手机',
        component: () => import('@/views/category'),
        children: [
          {
            path: '/phoneList/:type',
            component: () => import('@/views/phone/phoneList'),
            props: true,
            // 跳转到phoneinfo页面
          },
        ],
      },
      {
        path: '/phoneinfo/:category/:brand',
        component: () => import('@/views/phone/phoneinfo'),
        props: true,
      },
      {
        path: '/phoneListInfo/:id',
        component: () => import('@/views/phone/phoneListInfo'),
        props: true,
      },
    ],
  },
];

Vue.use(VueRouter);
// 创建router实例对象，去管理一组一组的路由规则

const router = new VueRouter({
  routes,
});

export default router;
